package com.pureut.order.controller;

/*** 
 *
 * Author:C
 * Date:2022/11/30 10:18
 * @DESC
 */

import com.pureut.common.core.domain.R;
import com.pureut.common.core.utils.bean.BeanUtils;
import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.order.domain.CustomerComplaintsManagement;
import com.pureut.order.dto.ConverterManagementDto;
import com.pureut.order.dto.CustomerComplaintsManagementDto;
import com.pureut.order.service.CustomerComplaintsManagementService;
import com.pureut.order.vo.ConverterManagementVo;
import com.pureut.order.vo.CustomerComplaintsManagementVo;
import com.pureut.order.vo.OrderReviewVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客诉管理控制层
 */
@RestController
@RequestMapping("/customer-complaints-management")
public class CustomerComplaintsManagementController extends BaseController {


    @Resource
    CustomerComplaintsManagementService customerComplaintsManagementService;


    /**
     * 客诉管理列表
     */
    @RequiresPermissions("order:complaints:list")
    @GetMapping("/list")
    public TableDataInfo list(CustomerComplaintsManagementVo customerComplaintsManagementVo) {
        startPage();
        //查询客诉管理列表
        List<CustomerComplaintsManagementDto> list = customerComplaintsManagementService.getList(customerComplaintsManagementVo);
        return getDataTable(list);
    }

    /**
     * 新增客诉管理
     */
    @RequiresPermissions("order:sale:complaints:add")
    @Log(title = "新增客诉管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CustomerComplaintsManagementVo customerComplaintsManagementVo) {
        return toAjax(customerComplaintsManagementService.addCustomerComplaintsManagement(customerComplaintsManagementVo));
    }

    /**
     * 修改
     */
    @RequiresPermissions("order:sale:complaints:edit")
    @Log(title = "修改客诉管理", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@Validated @RequestBody CustomerComplaintsManagementVo customerComplaintsManagementVo) {
        return toAjax(customerComplaintsManagementService.updateCustomerComplaintsById(customerComplaintsManagementVo));
    }

    /**
     * 提交审核
     */
    @RequiresPermissions("order:sale:complaints:subExamine")
    @Log(title = "提交审核", businessType = BusinessType.UPDATE)
    @GetMapping("/submitReview/{id}")
    public AjaxResult submitReview(@PathVariable("id") Long id) {
        return toAjax(customerComplaintsManagementService.submitReview(id));
    }

    /**
     * 撤销审核
     */
    @RequiresPermissions("order:sale:complaints:revoke")
    @Log(title = "撤销审核", businessType = BusinessType.UPDATE)
    @GetMapping("/deleteReview/{id}")
    public AjaxResult deleteReview(@PathVariable("id") Long id) {
        return toAjax(customerComplaintsManagementService.deleteReview(id));
    }

    /**
     * 删除客诉信息
     */
    @RequiresPermissions("order:sale:complaints:remove")
    @Log(title = "删除客诉信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}")
    public AjaxResult deleteReview(@PathVariable("ids") String ids) {
        return toAjax(customerComplaintsManagementService.deleteCustomerComplaintsManagement(ids));
    }

    /**
     * 查看
     */
    @RequiresPermissions("order:sale:complaints:query")
    @GetMapping("/viewSolution/{id}")
    public R<?> viewSolution(@PathVariable("id") Long id) {
        return R.ok(customerComplaintsManagementService.viewSolution(id));
    }

    /**
     * 客诉审核
     */
    @RequiresPermissions("order:sale:complaints:review")
    @Log(title = "客诉审核", businessType = BusinessType.UPDATE)
    @PostMapping("/complaintsReview")
    public AjaxResult complaintsReview(@Validated @RequestBody OrderReviewVo orderReviewVo) {
        return toAjax(customerComplaintsManagementService.complaintsReview(orderReviewVo));
    }

    /**
     * 方案审核
     */
    @RequiresPermissions("order:sale:complaints:programmeReview")
    @Log(title = "方案审核", businessType = BusinessType.UPDATE)
    @PostMapping("/programmeReview")
    public AjaxResult programmeReview(@Validated @RequestBody OrderReviewVo orderReviewVo) {
        return toAjax(customerComplaintsManagementService.programmeReview(orderReviewVo));
    }

}
